$('.list').mouseover(() => {
    $('.fruit').show()
})
$('.list').mouseout(() => {
    $('.fruit').hide()
})

// // 渲染二级菜单左边
const lists = document.querySelector('.list ')
// console.log(lists)
getList()
async function getList() {
    const res = await pAjax({ url: '/six', dataType: 'json' })
    // console.log(res)
    bindList(res.data.category)
}
function bindList(list) {
    let str = ''
    list.forEach(item => {

        str += `
        <li data-id="${item.id}">
        <p>${item.name}</p>
    </li>
        `
    })
    lists.innerHTML += str
}

// 渲染右边二级菜单
const fruits = document.querySelector('.fruit > .listChild')
console.log(fruits)

lists.addEventListener('mouseover', e => {
    if (e.target.nodeName === 'LI') {
        const id = e.target.dataset.id
        console.log(id)
        getFruit()
        async function getFruit() {
            let info = {
                type: `pc_index_category&id=${id}`,
            }
            const res = await pAjax({ url: '/abc', data: info, dataType: 'json' })
            console.log(res)
            bindHtml(res.data.secondary)
        }

        function bindHtml(list) {
            let str = ''
            list.forEach(item => {
                str +=
                    `
        <li>
            <img src="${item.pic}" alt="">
            <p>${item.name}</p>
        </li>
            `
            })
            fruits.innerHTML = str
        }
    }
    // console.log(id)


})




